<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="../../common/common.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>云众科技网上预约挂号系统</title>
	</head>

	<body>
		<div class="main-container" id="main-container">
			<!-- /section:basics/sidebar -->
			<div class="main-content">
				<div class="main-content-inner">
					<div class="page-content">
						<div class="row">
							<div class="col-xs-12">
								
							<!-- 检索  -->
							<form  method="post" name="infoForm" action="/illnessType/delete">
								<div class="container">
									<div class="col-sm-4" style="margin-top: 20px;">
										<div class="input-group">
											<input type="text" class="form-control" name="illtpName" placeholder="请输入疾病类型" value="${pd.illtpName }">
											<div class="input-group-btn">
												<button type="button" class="btn btn-warning" title="查询" onclick="doSearch()"><span class="glyphicon glyphicon-search"></span></button>
											</div>
											<div class="input-group-btn">
												<button type="button" class="btn btn-danger" title="清空" onclick="cleanUp()"><span class="glyphicon glyphicon-minus"></span></button>
											</div>
									    </div>
							    	</div>
							    	<div class="col-sm-6"></div>
							    	<div class="col-sm-2" style="margin-top: 20px;">
										<div class="form-group">
											<button type="button" class="btn btn-primary" title="增加" onclick="addpage()"><span class="glyphicon glyphicon-plus"></span></button>
											<button type="button" class="btn btn-danger" title="批量删除" onclick="del()"><span class="glyphicon glyphicon-trash"></span></button>
									    </div>
							    	</div>
							    </div>
								<table id="simple-table" class="table table-striped table-hover" style="margin-top:5px;">	
									<thead>
										<tr class="bg-primary">
											<td align="center">
<%--												<input type="checkbox" id="zcheckbox" onclick="selectAll()"/>--%>
<%--													<font style="color: white;">全选</font>--%>
											<a href="javascript:selectAll()"><font style="color: white;">全选</font></a>
											</td>
											<td align="center">疾病类型</td>
											<td align="center">操作</td>
										</tr>
									</thead>
															
									<tbody>
									<!-- 开始循环 -->	
<%--									<c:choose>--%>
<%--										<c:when test="${not empty page.list}">--%>
											<c:forEach items="${page.list}" var="ilt" varStatus="i">
												<tr>
													<td align="center">
														<input type='checkbox' name='ids' value="${ilt.illtpId}" />
													</td>
													<td align="center">${ilt.illtpName }</td>
													<td align="center">
														<button type="button" class="btn btn-primary" title="修改" onclick="editpage('${ilt.illtpId}')"><span class="glyphicon glyphicon-edit"></span></button>
<%--														<button type="button" class="btn btn-danger" title="删除" onclick="delOne('${ilt.illtpId}')"><span class="glyphicon glyphicon-minus"></span></button>--%>
													</td>
												</tr>
											</c:forEach>
<%--										</c:when>--%>
<%--										<c:otherwise>--%>
<%--											<tr class="main_info">--%>
<%--												<td colspan="100" class="center" >没有相关数据</td>--%>
<%--											</tr>--%>
<%--										</c:otherwise>--%>
<%--									</c:choose>--%>
									</tbody>
								</table>
								<div align="center">
									<yzpage:page pageName="page" url="/illnessType/query"></yzpage:page>
								</div>
							</form>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</body>
	<script type="text/javascript">
	function editpage(id){
		location.href = "/illnessType/editpage?id="+id;
	}
	function addpage(){
		location.href = "/illnessType/addpage";
	}
	// function delOne(id){
	// 	bootbox.confirm("确定要删除吗?", function(result) {
	// 		if(result){
	// 			location.href = "/illnessType/delete?ids="+id;
	// 		}
	// 	})
	// }

	//清空
	function cleanUp(){

		$("input[name='illtpName']").val("");
	}


	function doSearch(){
		$("form[name='infoForm']").attr("action","/illnessType/query");
		$("form[name='infoForm']").submit();
	}
	//全选
	function selectAll(){
		var inpts = $("input[name='ids']");
		for(var i=0;i<inpts.length;i++){
			if(inpts[i].checked!=true){
				inpts[i].checked=true;
			}else{
				inpts[i].checked=false;
			}
		}
	}
	
	// //批量操作
	// function del(){
	// 	bootbox.confirm("'确定要删除选中的数据吗?", function(result) {
	// 		if(result) {
	// 			var checked = $("form[name='infoForm'] :input:checked");
	//
	// 			if(checked.length==0){
	// 				bootbox.dialog({
	// 					message: "<span class='bigger-110'>您没有选择任何内容!</span>",
	// 					buttons:
	// 					{ "button":{ "label":"确定", "className":"btn-sm btn-success"}}
	// 				});
	// 				$("#zcheckbox").tips({
	// 					side:1,
	// 		            msg:'点这里全选',
	// 		            bg:'#AE81FF',
	// 		            time:8
	// 		        });
	// 				return;
	// 			}else{
	// 				$("form[name='infoForm']").attr("action","/sys/removePerson");
	// 				$("form[name='infoForm']").submit();
	// 			}
	// 		}
	// 	});
	// };

	function del(){
		var delids = $("input[name='ids']:checked");
		if(delids.length==0){
			bootbox.alert("请先选择要删除的记录！");
			return;
		}
		bootbox.confirm("确定要删除吗？",function(r){
			if(r){
				var url = "/illnessType/delete";
				var data = $("form[name='infoForm']").serialize();
				$.post(url, data, function(responseData) {
					if (responseData.success) {
						bootbox.alert("删除成功",function(){
							location.reload();
						});
					} else {
						bootbox.alert("删除失败,"+responseData.msg+"被使用,不能删除",function(){
							location.reload();
						});
					}
				}, "json")
			}
		});
	}

	</script>
</html>